﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using JChatData.Helper;
using System.IO;
using JChatSerVices.GetConnect;
using JChatSerVices.UserService;
using JChatCore.User;
using JChatAdmin.Models.LoginModel;

namespace JChatAdmin.Controllers
{
    public class LoginController : Controller
    {
        //
        //GET: /Login/
        UserService _user;

        public LoginController()
        {
            _user = new UserService();
        }
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Login()
        {

            return View();
        }
        [HttpPost]
        public ActionResult Login(LoginModel model)
        {
            if (_user.Login(model.UserName, model.Password))
            {
                System.Web.HttpContext.Current.Session["user"] = model.UserName;
                return RedirectToAction("Index", "Admin");
            }
            else
            {
                return RedirectToAction("Login", "Admin");
            }
        }

    }
}